package com.mindskip.xzs.viewmodel.admin.question;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.poi.excel.cell.CellUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.constraints.Range;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Description:
 *
 * @author zhangjl
 * @date 2021/9/7 22:38
 */
@Data
@Slf4j
public class ExcelVo {

    private Integer questionType;

    private Long subjectId;

    private String title;

    private Integer gradeLevel;

    private List<QuestionEditItemVM> items;

    private String analyze;

    private List<String> correctArray;

    private String correct;

    private String score;

    private Integer difficult;

    private String item;

    public void buildItems(){
        if(CollectionUtil.isEmpty(this.items)){
            this.items=new ArrayList<>();
        }

        for (String s : item.split(",")) {
            String[] split = s.split(":");
            QuestionEditItemVM questionEditItemVM = new QuestionEditItemVM(split[0], split[1]);
            log.info("=======================================");
            log.info(questionEditItemVM.toString());
            log.info("=======================================");
            this.items.add(questionEditItemVM);
        }
    }
}
